import { Card ,Descriptions,Button} from "antd";
import React, { useEffect, useState } from "react";
import {getHosListDetailRequest} from '@api/hospital/hospitalListRequest'
import { useNavigate, useParams } from "react-router-dom";
import {BookingRule, getHosListDetailReturnType,hospitalListItemsType} from '@api/hospital/model/hospitalListTypes'

export default function Hospitalshow() {
    const [detail,setDetial] = useState<getHosListDetailReturnType>({})
    const {id} = useParams()
    const navigate = useNavigate()
    useEffect(() => {
        const getHosListDetail = async () => {
            const re = await getHosListDetailRequest(id as string)
            setDetial(re)
        }
        getHosListDetail()
    },[])
  return (
    <Card>
      <Descriptions
        title="基本信息"
        bordered
        column={2}
      >
        <Descriptions.Item label="医院名称">{(detail.hospital as hospitalListItemsType)?.hosname}</Descriptions.Item>
        <Descriptions.Item label="医院logo">
            {(detail.hospital as hospitalListItemsType)?
            <img width={200} src={`data:image/jpeg;base64,${(detail.hospital as hospitalListItemsType)?.logoData}`} alt="" />:
            ('')
            }
            </Descriptions.Item>
        <Descriptions.Item label="医院编码">{(detail.hospital as hospitalListItemsType)?.hoscode}</Descriptions.Item>
        <Descriptions.Item label="医院地址">{(detail.hospital as hospitalListItemsType)?.param.fullAddress}</Descriptions.Item>
        <Descriptions.Item label="坐车路线" span={2}>{(detail.hospital as hospitalListItemsType)?.route}</Descriptions.Item>
        <Descriptions.Item label="医院简介" span={2}>{(detail.hospital as hospitalListItemsType)?.intro}</Descriptions.Item>
      </Descriptions>
      <Descriptions
        title="预约规则信息"
        bordered
        column={2}
        style={{marginTop:'30px'}}
      >
        <Descriptions.Item label="预约周期">{(detail.bookingRule as BookingRule)?.cycle}</Descriptions.Item>
        <Descriptions.Item label="放号时间">{(detail.bookingRule as BookingRule)?.releaseTime}</Descriptions.Item>
        <Descriptions.Item label="停挂时间">{(detail.bookingRule as BookingRule)?.stopTime}</Descriptions.Item>
        <Descriptions.Item label="退号时间">{(detail.bookingRule as BookingRule)?.quitTime}</Descriptions.Item>
        <Descriptions.Item label="预约规则" span={2}>{(detail.bookingRule as BookingRule)?.rule}</Descriptions.Item>
      </Descriptions>
      <Button style={{marginTop:'30px'}} onClick={() => {navigate(-1)}}>返回</Button>
    </Card>
  );
}
